<div class="ibox-content">
    <form class="form-horizontal" method="post" action="{:url('Package/addpack')}">
        <input type="hidden" name="id" value="{$info.id|default='0'}">
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('模块标题')}</label>
            <div class="col-sm-2">
                <input name="title" class="form-control" type="text" placeholder="{:lang('请输入模块标题')}"
                       value="{$info.title|default=''}" required/>
                <span class="help-block m-b-none"></span>
            </div>
            <label class="col-sm-1 control-label">{:lang('module name')}</label>
            <div class="col-sm-2">
                <input name="name" class="form-control" type="text" placeholder="{:lang('请输入模块名')}" value="{$info.name|default=''}"
                       readonly/>
            </div>
            <label class="col-sm-1 control-label">{:lang('加密打包')}</label>
            <div class="col-sm-2">
                <div class="checkbox text-danger">
                    <input type="checkbox" id="visible1" value="1" name="is_encode" checked>
                    <label for="visible1"> {:lang('yes')} </label>
                </div>
                <span class="help-block m-b-none"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('version')}</label>
            <div class="col-sm-2">
                <input name="version" class="form-control" type="text" placeholder="{:lang('输入')}{:lang('version')}"
                       value="{$info.version|default=''}"/>
                <span class="help-block m-b-none"></span>
            </div>
            <label class="col-sm-1 control-label">{:lang('author')}</label>
            <div class="col-sm-2">
                <input name="author" class="form-control" type="text" placeholder="{:lang('输入')}{:lang('author')}"
                       value="{$info.author|default=''}"/>
                <span class="help-block m-b-none"></span>
            </div>
            <label class="col-sm-1 control-label">{:lang('author website')}</label>
            <div class="col-sm-4">
                <input name="author_url" class="form-control" type="text" placeholder="{:lang('输入')}{:lang('author website')}"
                       value="{$info.author_url|default=''}"/>
                <span class="help-block m-b-none"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('模块')}{:lang('description')}</label>
            <div class="col-sm-10">
                <textarea name="intro" class="form-control" cols="80" rows="2">{$info.intro|default=''}</textarea>
                <span class="help-block m-b-none"></span></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('关联数据表')}</label>
            <div class="col-sm-10">
                <textarea name="tables" class="form-control" cols="80" rows="10">{$info.tables|default=''}</textarea>
                <span class="help-block m-b-none">{:lang('关联数据表是指模块所需要的数据表名称')}，{:lang('如果有多个表用英文逗号')}（,）{:lang('分隔')}。如：table1,table2</span></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">{:lang('数据文件')}</label>
            <div class="col-sm-10">
                <textarea name="data_file_list" class="form-control" cols="80" rows="5"></textarea>
                <span class="help-block m-b-none">{:lang('临时打包一些配置文件')}，{:lang('如')}：/public/static/</span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-8">
                <button type="button" class="btn  btn-info ajax-save-post" target-form="form-horizontal"
                        data-loading-text="Loading...">
                    <span class="ladda-label"> {:lang('确定打包')} </span>
                </button>
            </div>
        </div>
    </form>
</div>

<div class="ibox-title">
    {:lang('打包信息')}

</div>

<div class="ibox-content">
    <div class="row">
        <div class="col-sm-12 package-log"></div>
    </div>
</div>

<script>
    var fakeloaderBox='';

    $(document).ready(function () {
        //删除选中产品
        $("body").on("click", ".ajax-save-post", function () {
            var target, query, form;
            var target_form = $(this).attr('target-form');
            form = $('.' + target_form);
            query = form.serialize();
            target = form.get(0).action;
            $.ajax({
                type: "POST",
                url: target,
                data: query,
                dataType: "json",
                beforeSend: function(){
                    $('.fakeloader').html('<div class="ibox-content">{:lang('正在打包中请务操作其它')}</div>');
                    fakeloaderBox=layer.open({
                        type: 1,
                        shade: [0.2, '#393D49'],
                        title: false, //不显示标题
                        content: $('.fakeloader'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                        cancel: function(){
                            //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
                        }
                    });
                },
                success: function (result) {
                    if (result.code == '1') {
                        layer.msg(result.msg, {icon: 1, time: 500, shade: [0.5, '#000', true]}, function () {
                            $('.package-log').html(result.data);
                            layer.close(fakeloaderBox);
                        });
                    } else {
                        layer.msg(result.msg, {icon: 5});
                    }
                }
            });//end ajax post
        });
    })
</script>